﻿using NP.BPMReportPlatform.ElectronicSign;
using NP.BPMReportPlatform.ElectronicSign.Dto;
using NP.BPMReportPlatform.Entities.BPM_Platform;
using System.IO;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;

namespace NP.BPMReportPlatform.ElectronicSign
{
    /// <summary>
    /// ES对外接口
    /// </summary>
    public interface IESService : IApplicationService
    {
        /// <summary>
        /// 检查外部用户是否存在(不存在则创建)
        /// </summary>
        /// <param name="workNumber"></param>
        /// <returns>返回用户的电子签id</returns>
        Task<string> CheckSignUser(string workNumber);

        /// <summary>
        /// 检查外部企业是否存在
        /// </summary>
        /// <param name="corporateCode">甲方编码</param>
        /// <returns>返回调用后的甲方实体(如何使用请自己判断)</returns>
        Task<CorporateEntity> CheckSignCompany(string corporateCode);

        /// <summary>
        /// 检查外部企业是否存在
        /// </summary>
        Task CheckAllCompany();

        /// <summary>
        /// 上传
        /// </summary>
        /// <param name="businessCode"></param>
        /// <param name="fileStream">文件流</param>
        /// <returns></returns>
        Task<string> UploadSignFile(string businessCode, byte[] fileStream);

        /// <summary>
        /// 发起合同签署
        /// </summary>
        /// <param name="businessCode"></param>
        /// <param name="eSBusinessEnum">枚举</param>
        /// <returns></returns>
        Task<string> CreateSignFlow(string businessCode, ESBusinessEnum eSBusinessEnum);

        /// <summary>
        /// 电子签状态回调接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<ESDto.ESCommonResponseForOne> UpdateSignStatus(ESDto.ESFlowRequest request);

        /// <summary>
        /// 催办接口
        /// </summary>
        /// <param name="contractCode"></param>
        /// <returns></returns>
        Task SignFlowReminder(string contractCode);


        /// <summary>
        /// 作废
        /// </summary>
        /// <param name="contractCode"></param>
        /// <returns></returns>
        Task<string> SignFlowCancel(string contractCode);

        /// <summary>
        /// 文件下载URL获取
        /// </summary>
        /// <param name="flowid">流程号</param>
        /// <returns></returns>
        Task<string> GetESDownloadUrl(string flowid);

        /// <summary>
        /// 获取签署情况
        /// 流程状态，0草稿，1签署中，2完成，3撤销，4终止，5过期，6删除，7拒签，8作废，9已归档，10预盖章
        /// </summary>
        /// <param name="flowid">流程号</param>
        /// <returns></returns>
        Task<string> GetSignDetail(string flowid);
    }
}
